package com.cskaoyan._01btyestream.buffer;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/17 17:24
 **/
/*
字节缓冲输出流
1.创建输出流对象
2.write写数据
3.flush
4.close

 */
public class Demo {
    public static void main(String[] args) throws IOException {
        // 1.创建输出流对象
        BufferedOutputStream out = new BufferedOutputStream(
                new FileOutputStream(new File("a.txt")));
        //2.write写数据
        // write(int b)
        out.write(97);
        out.write(System.lineSeparator().getBytes());
        // write(byte[] b)
        out.write("yyds".getBytes());
        out.write(System.lineSeparator().getBytes());

        // write(byte[] b, int off,int len)
        out.write("abcd".getBytes(), 1, 3);

        //3.flush
        out.flush();

        //4.close
        out.close();
    }
}
